package com.api.service.impl;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.api.common.reqres.Request;
import com.api.common.reqres.Response;
import com.api.component.RequestComponent;
import com.api.component.ResponseComponent;
import com.api.mapper.BaseDataMapper;
import com.api.model.request.TestRequest;
import com.api.model.response.TestResponse;
import com.api.service.TestService;

import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class TestServiceImpl implements TestService {

	@Autowired
	private ResponseComponent responseComponent;
	@Autowired
	private BaseDataMapper baseDataMapper;
	@Autowired
	private RequestComponent requestComponent;

	@Override
	public Response<TestResponse> test(Request<TestRequest> request) {
		requestComponent.checkBody(request.getBody(), TestRequest.class);
		// TODO Auto-generated method stub
//		log.info(request.getBody().getName());
//		log.info(request.getBody().getPhone());
		Response<TestResponse> response = new Response<TestResponse>();
//		log.info(bWeixininfoMapper + "");
// 		主键查询
//		BWeixininfo BWeixininfo = bWeixininfoMapper.selectById(1);
//		log.info(BWeixininfo.getNickname());
//		查询所有记录 
//		List<BWeixininfo> bWeixininfoList = bWeixininfoMapper.selectList(null);
//		log.info(bWeixininfoList.size() + "");

		// 分页
//		Page<BWeixininfo> page = new Page<BWeixininfo>();
//		page.setCurrent(1);
//		page.setSize(1);
//		IPage<BWeixininfo> pageList = bWeixininfoMapper.selectPageVo(page, 1);
//		log.info(pageList.getRecords().size() + "");
//		log.info(pageList.getTotal() + "");
		// 待条件查询
//		QueryWrapper<BWeixininfo> queryWrapper = new QueryWrapper<BWeixininfo>();
//		queryWrapper.eq("individualid", "1");
//		List<BWeixininfo> bWeixininfoList = bWeixininfoMapper.selectList(queryWrapper);
//		log.info(bWeixininfoList.size() + "");
//		BWeixininfo bWeixininfo = bWeixininfoMapper.selectOne(queryWrapper);
//		log.info(bWeixininfo.getNickname() + "");
//
//		TestResponse testResponse = new TestResponse();
//		testResponse.setName(bWeixininfo.getNickname());
//		response.setData(testResponse);
//		boolean b = true;
//		if (b) {
//			throw new RuntimeException("sdfas");
//		}
//
//		for (int i = 0; i < 2; i++) {
//			BaseData baseData = new BaseData();
//			baseData.setType("p" + i);
//			baseData.setTypename("父类" + i);
//			baseData.setStatus(true);
//			for (int j = 0; j < 2; j++) {
//				baseData.setCode("z" + j);
//				baseData.setCodename("子类" + j);
//				baseData.setCreateuser("system");
//				baseData.setCreatetime(LocalDateTime.now());
//				baseDataMapper.insert(baseData);
//			}
//		}
		return responseComponent.toSuccess(response);
	}

}
